package com.objectproject.main.service.subsystem.utility;

import java.util.ArrayList;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.objectproject.main.model.MyObject;
import com.objectproject.main.model.MyProperty;
import com.objectproject.main.model.primitive.MyPrimitive;
import com.objectproject.main.service.MyObjectServiceImpl;

@Service
public class PropertyUtility {
	
	@Autowired
	MyObjectServiceImpl myObjectServiceImpl;
	
	@Autowired
	PrimitiveUtility primitiveUtility;
	
	public ArrayList<MyProperty> extractIsNextProperty(ArrayList<MyProperty> myProperties){
		
		ArrayList<MyProperty> resultProperties = new ArrayList<MyProperty>();
		
		for(int i = 0 ; i < myProperties.size() ; i++){
			if(!myProperties.get(i).isNext()){
				resultProperties.add(myProperties.get(i));
			}
		}
		
		return resultProperties;
	}
	
	public long insertMyPropertyValueEasy(Object object){
		
		long insertedId = 0L;
		
		if(object instanceof MyObject){
			//myObjectServiceImpl.createMyObject(myObject, superObjects, locale)
			//이럴일은 없다고 가정한다. 오브젝트의 경우 미리 입력해주어야함
		}else if(object instanceof MyPrimitive){
			insertedId = primitiveUtility.insertMyPrimitiveEasy((MyPrimitive)object);
		}else{
			//throw exception;
		}
		return insertedId;
		
	}

	public void setPrioritiesByOrdering(ArrayList<MyProperty> myProperties){
		//상위객체와의 속성 문제때문에 에러날듯
	}
}
